home *** CD-ROM | disk | FTP | other *** search
- ' DIALER.BAS
- ' A program that searches a database file for a name you want
- ' and dials that person's telephone number for you. The program
- ' assumes the existence of a database file named CONTACTS.TXT
- ' in the current drive and directory and assumes that you have
- ' a Hayes-compatible modem attached to COM1.
-
- DECLARE SUB DialNumber ()
- OPTION BASE 1
- DIM SHARED HomeAC$ ' Your local area code
- DIM SHARED Name$(4, 16) ' Array to hold each name and phone number
- DIM SHARED NumNames% ' Number of names found in database
- filename$ = "CONTACTS.TXT" ' Name of contacts database file
- form$ = "\ \ \ \ (\ \)-\ \"
-
- HomeAC$ = "415" ' Your local area code; change when traveling
-
- DO
-
- NumNames% = 0: search$ = "": hit% = 0
-
- OPEN filename$ FOR INPUT AS #1
- CLS : LOCATE 3, 15: PRINT "SEARCH for a name in the database"
- LOCATE 4, 15: PRINT "(To stop, enter END as the name)"
- LOCATE 6, 15: INPUT "Enter name to search for:"; search$: PRINT
- IF UCASE$(search$) = "END" THEN SYSTEM ' Quit program and return to DOS
-
- DO WHILE (NOT EOF(1))
- INPUT #1, last$, first$, area$, phone$
- test$ = UCASE$(search$)
- IF UCASE$(last$) = test$ OR UCASE$(first$) = test$ THEN
- hit% = 1: NumNames% = NumNames% + 1
- Name$(1, NumNames%) = last$: Name$(2, NumNames%) = first$
- Name$(3, NumNames%) = area$: Name$(4, NumNames%) = phone$
- IF NumNames% <= 9 THEN LOCATE , 15: PRINT NumNames%; "- ";
- IF NumNames% > 9 THEN LOCATE , 14: PRINT NumNames%; "- ";
- PRINT USING form$; last$; first$; area$; phone$
- END IF
- LOOP
-
- IF hit% <> 0 THEN
- DialNumber
- ELSE
- LOCATE , 15: PRINT "No match found for "; search$
- LOCATE , 15: PRINT "Press any key to continue"
- DO WHILE INKEY$ = "": LOOP
- END IF
-
- CLOSE #1
- LOOP
-
- SUB DialNumber
- LOCATE 3, 15: PRINT "Be sure your modem is turned on! "
- LOCATE 4, 15: PRINT "You must pick up the handset by the second ring."
-
- DO
- LOCATE 6, 65: PRINT " ": LOCATE 6, 15
- INPUT "Enter the number of the person you'd like to call: ", choice%
- LOOP UNTIL choice% >= 1 AND choice% <= NumNames%
-
- PhoneNum$ = "": CLS : LOCATE 3, 15: PRINT "Dialing: ";
- PRINT Name$(2, choice%); " "; Name$(1, choice%); " ";
- IF Name$(3, choice%) <> "" THEN
- IF Name$(3, choice%) = HomeAC$ THEN
- PhoneNum$ = ""
- ELSE
- PhoneNum$ = "1," + Name$(3, choice%)
- PRINT "("; Name$(3, choice%); ")-";
- END IF
- END IF
- PRINT Name$(4, choice%)
-
- ' If some numbers in your home area code require
- ' that you first dial 1 before some numbers, remove
- ' the leading apostrophes from the following seven lines.
- ' IF Name$(3, choice%) = HomeAC$ THEN
- ' DO
- ' LOCATE 5, 15
- ' INPUT "Do you need to dial a 1 first (Y or N)"; One$
- ' LOOP UNTIL UCASE$(One$) = "Y" OR UCASE$(One$) = "N"
- ' IF UCASE$(One$) = "Y" THEN PhoneNum$ = "1,"
- ' END IF
-
- PhoneNum$ = PhoneNum$ + Name$(4, choice%)
- OPEN "COM1:1200,e,7,1,BIN,CD0,CS0,DS0,OP0" FOR RANDOM AS #2
- PRINT #2, "ATS7=9DT", PhoneNum$
- LOCATE 5, 15: PRINT "Pick up the phone before the second ring."
- LOCATE 7, 15
- PRINT "After picking up the phone, press any key to continue."
- DO: LOOP UNTIL INKEY$ <> ""
- PRINT #2, ATS7 = 30 ' Reset the value of S7 to maximum
- CLOSE #2
-
- END SUB
-